package bb.lanxing.lib.devices.ble.ble.services;

//import com.alipay.sdk.packet.d;
import bb.lanxing.lib.devices.ble.ble.base.BaseBleSensorDevice;
import bb.lanxing.lib.devices.ble.ble.base.BaseBleService;
import bb.lanxing.lib.devices.ble.ble.characteristic.BatteryCharacteristics;
import bb.lanxing.lib.devices.ble.ble.characteristic.BatteryStatusCharacteristic;
import bb.lanxing.lib.devices.core.ble.SpecificationAttributes;
import java.util.UUID;
import kotlin.Metadata;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt;
import kotlin.coroutines.jvm.internal.ContinuationImpl;
import kotlin.jvm.internal.Intrinsics;
/* compiled from: BatteryService.kt */

public final class BatteryService extends BaseBleService {
    private BatteryCharacteristics batteryLevelCharacteristic;
    private BatteryStatusCharacteristic batteryStatusCharacteristic;

    public BatteryService(BaseBleSensorDevice device) {
        super(device);
//        Intrinsics.checkNotNullParameter(device, "device");
    }

    public BatteryCharacteristics getBatteryLevelCharacteristic() {
        return this.batteryLevelCharacteristic;
    }

    public void setBatteryLevelCharacteristic(BatteryCharacteristics batteryCharacteristics) {
        this.batteryLevelCharacteristic = batteryCharacteristics;
    }

    public BatteryStatusCharacteristic getBatteryStatusCharacteristic() {
        return this.batteryStatusCharacteristic;
    }

    public void setBatteryStatusCharacteristic(BatteryStatusCharacteristic batteryStatusCharacteristic) {
        this.batteryStatusCharacteristic = batteryStatusCharacteristic;
    }

    @Override
    public UUID targetUUID() {
        UUID BLE_BATTERY_SERVICE = SpecificationAttributes.BLE_BATTERY_SERVICE;
        Intrinsics.checkNotNullExpressionValue(BLE_BATTERY_SERVICE, "BLE_BATTERY_SERVICE");
        return BLE_BATTERY_SERVICE;
    }

    public final class BatteryService$initialization$1 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        int label;
        Object result;
        final BatteryService this$0;

        public BatteryService$initialization$1(BatteryService batteryService, Continuation<? super BatteryService$initialization$1> continuation) {
            super((Continuation<Object>) continuation);
            this.this$0 = batteryService;
        }

        @Override
        public Object invokeSuspend(Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return this.this$0.initialization(this);
        }
    }
    @Override
    public Object initialization(Continuation<? super Unit> continuation) {
        BatteryService$initialization$1 batteryService$initialization$1;
        Object coroutine_suspended;
        int i;
        BatteryService batteryService = null;
        BatteryService batteryService2 = null;
        BatteryCharacteristics batteryCharacteristics = null;
        BatteryStatusCharacteristic batteryStatusCharacteristic;
        BatteryStatusCharacteristic batteryStatusCharacteristic2;
        BatteryService batteryService3;
        BatteryStatusCharacteristic batteryStatusCharacteristic3;
        BatteryService batteryService4;
        BatteryStatusCharacteristic batteryStatusCharacteristic4;
        if (continuation instanceof BatteryService$initialization$1) {
            batteryService$initialization$1 = (BatteryService$initialization$1) continuation;
            if ((batteryService$initialization$1.label & Integer.MIN_VALUE) != 0) {
                batteryService$initialization$1.label -= Integer.MIN_VALUE;
                Object obj = batteryService$initialization$1.result;
                coroutine_suspended = IntrinsicsKt.getCOROUTINE_SUSPENDED();
                i = batteryService$initialization$1.label;
                if (i != 0) {
                    ResultKt.throwOnFailure(obj);
                    BatteryCharacteristics batteryCharacteristics2 = new BatteryCharacteristics(this);
                    batteryService$initialization$1.L$0 = this;
                    batteryService$initialization$1.L$1 = batteryCharacteristics2;
                    batteryService$initialization$1.L$2 = this;
                    batteryService$initialization$1.label = 1;
                    if (batteryCharacteristics2.readSynced(batteryService$initialization$1) == coroutine_suspended) {
                        return coroutine_suspended;
                    }
                    batteryService = this;
                    batteryService2 = batteryService;
                    batteryCharacteristics = batteryCharacteristics2;
                } else if (i != 1) {
                    if (i != 2) {
                        if (i == 3) {
                            batteryService4 = (BatteryService) batteryService$initialization$1.L$2;
                            batteryStatusCharacteristic4 = (BatteryStatusCharacteristic) batteryService$initialization$1.L$1;
                            batteryStatusCharacteristic3 = (BatteryStatusCharacteristic) batteryService$initialization$1.L$0;
                            ResultKt.throwOnFailure(obj);
                            batteryStatusCharacteristic4.enableNotify();
                            batteryService4.batteryStatusCharacteristic = batteryStatusCharacteristic3;
                            return Unit.INSTANCE;
                        }
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    batteryService3 = (BatteryService) batteryService$initialization$1.L$3;
                    batteryStatusCharacteristic2 = (BatteryStatusCharacteristic) batteryService$initialization$1.L$2;
                    batteryService2 = (BatteryService) batteryService$initialization$1.L$0;
                    ResultKt.throwOnFailure(obj);
                    batteryStatusCharacteristic = (BatteryStatusCharacteristic) batteryService$initialization$1.L$1;
                    batteryService$initialization$1.L$0 = batteryStatusCharacteristic;
                    batteryService$initialization$1.L$1 = batteryStatusCharacteristic2;
                    batteryService$initialization$1.L$2 = batteryService3;
                    batteryService$initialization$1.L$3 = null;
                    batteryService$initialization$1.label = 3;
                    if (batteryService2.delayInPeer(batteryService$initialization$1) != coroutine_suspended) {
                        return coroutine_suspended;
                    }
                    batteryStatusCharacteristic3 = batteryStatusCharacteristic;
                    batteryService4 = batteryService3;
                    batteryStatusCharacteristic4 = batteryStatusCharacteristic2;
                    batteryStatusCharacteristic4.enableNotify();
                    batteryService4.batteryStatusCharacteristic = batteryStatusCharacteristic3;
                    return Unit.INSTANCE;
                } else {
                    batteryService = (BatteryService) batteryService$initialization$1.L$2;
                    batteryCharacteristics = (BatteryCharacteristics) batteryService$initialization$1.L$1;
                    batteryService2 = (BatteryService) batteryService$initialization$1.L$0;
                    ResultKt.throwOnFailure(obj);
                }
                batteryService.batteryLevelCharacteristic = batteryCharacteristics;
                batteryStatusCharacteristic = new BatteryStatusCharacteristic(batteryService2);
                batteryService$initialization$1.L$0 = batteryService2;
                batteryService$initialization$1.L$1 = batteryStatusCharacteristic;
                batteryService$initialization$1.L$2 = batteryStatusCharacteristic;
                batteryService$initialization$1.L$3 = batteryService2;
                batteryService$initialization$1.label = 2;
                if (batteryStatusCharacteristic.readSynced(batteryService$initialization$1) != coroutine_suspended) {
                    return coroutine_suspended;
                }
                batteryStatusCharacteristic2 = batteryStatusCharacteristic;
                batteryService3 = batteryService2;
                batteryService$initialization$1.L$0 = batteryStatusCharacteristic;
                batteryService$initialization$1.L$1 = batteryStatusCharacteristic2;
                batteryService$initialization$1.L$2 = batteryService3;
                batteryService$initialization$1.L$3 = null;
                batteryService$initialization$1.label = 3;
                if (batteryService2.delayInPeer(batteryService$initialization$1) != coroutine_suspended) {
                }
            }
        }
        batteryService$initialization$1 = new BatteryService$initialization$1(this, (Continuation<? super BatteryService$initialization$1>) continuation);
        Object obj2 = batteryService$initialization$1.result;
        coroutine_suspended = IntrinsicsKt.getCOROUTINE_SUSPENDED();
        i = batteryService$initialization$1.label;
        if (i != 0) {
        }
        batteryService.batteryLevelCharacteristic = batteryCharacteristics;
        batteryStatusCharacteristic = new BatteryStatusCharacteristic(batteryService2);
        batteryService$initialization$1.L$0 = batteryService2;
        batteryService$initialization$1.L$1 = batteryStatusCharacteristic;
        batteryService$initialization$1.L$2 = batteryStatusCharacteristic;
        batteryService$initialization$1.L$3 = batteryService2;
        batteryService$initialization$1.label = 2;
        if (batteryStatusCharacteristic.readSynced(batteryService$initialization$1) != coroutine_suspended) {
        }
        return coroutine_suspended;
    }
}
